
#pragma once

const std::string sendStoreReqMessageQueueName_ = "ReloadSendStoreReqMessageQueue";
const std::string sendFetchReqMessageQueueName_ = "ReloadSendFetchReqMessageQueue";
const std::string sendAppAttachReqMessageQueueName_ = "ReloadSendAppAttachReqMessageQueue";

class SerializeString : public asyframe::NumericVarArray<asyframe::byte, asyframe::byte>
{
public:
	SerializeString();
	SerializeString(const std::vector<asyframe::byte>& _array);
	SerializeString(const char* _cstr);
	SerializeString(const std::string& _str);
	virtual ~SerializeString();

	retT setValue(const std::vector<asyframe::byte>& _array);
	retT setValue(const char* _cstr);
	retT setValue(const std::string& _str);

	std::string toString();
};

class IPCCallPacketBase : public asyframe::PacketElement
{
public:
	IPCCallPacketBase();
	virtual ~IPCCallPacketBase();

	virtual retT readFromBufferNoCheck( boost::shared_ptr<asyframe::IoBuffer> _pBuffer);
	virtual retT writeToBufferNoCheck( boost::shared_ptr<asyframe::IoBuffer> _pBuffer);

	virtual retT readFromBuffer( boost::shared_ptr<asyframe::IoBuffer> _pBuffer);
	virtual retT writeToBuffer( boost::shared_ptr<asyframe::IoBuffer> _pBuffer);

	virtual std::size_t size();
	virtual retT attachRootElement(boost::weak_ptr<asyframe::PacketElement> _pRootElement);

	SerializeString	messageQueueName_;
	SerializeString	overlayInstanceName_;
	SerializeString	resourceName_;
};

class SendStoreReqIPCCallPacket : public IPCCallPacketBase
{
public:
	SendStoreReqIPCCallPacket();
	virtual ~SendStoreReqIPCCallPacket();

	virtual retT readFromBuffer( boost::shared_ptr<asyframe::IoBuffer> _pBuffer);
	virtual retT writeToBuffer( boost::shared_ptr<asyframe::IoBuffer> _pBuffer);

	virtual std::size_t size();

	boost::shared_ptr<reload::ReloadPacket> pReloadPacket_;
};

class SendFetchReqIPCCallPacket : public IPCCallPacketBase
{
public:
	SendFetchReqIPCCallPacket();
	virtual ~SendFetchReqIPCCallPacket();

	virtual retT readFromBuffer( boost::shared_ptr<asyframe::IoBuffer> _pBuffer);
	virtual retT writeToBuffer( boost::shared_ptr<asyframe::IoBuffer> _pBuffer);

	virtual std::size_t size();

	boost::shared_ptr<reload::ReloadPacket> pReloadPacket_;
};

class IPCCallResultBase : public asyframe::PacketElement
{
public:
	IPCCallResultBase();
	virtual ~IPCCallResultBase();

	virtual retT readFromBufferNoCheck( boost::shared_ptr<asyframe::IoBuffer> _pBuffer);
	virtual retT writeToBufferNoCheck( boost::shared_ptr<asyframe::IoBuffer> _pBuffer);

	virtual retT readFromBuffer( boost::shared_ptr<asyframe::IoBuffer> _pBuffer);
	virtual retT writeToBuffer( boost::shared_ptr<asyframe::IoBuffer> _pBuffer);

	virtual std::size_t size();

	int result_;
};

class SendFetchReqIPCCallResult : public IPCCallResultBase
{
public:
	SendFetchReqIPCCallResult();
	virtual ~SendFetchReqIPCCallResult();

	virtual retT readFromBuffer( boost::shared_ptr<asyframe::IoBuffer> _pBuffer);
	virtual retT writeToBuffer( boost::shared_ptr<asyframe::IoBuffer> _pBuffer);

	virtual std::size_t size();

	boost::shared_ptr<reload::ReloadPacket> pReloadPacket_;
};

class SendAppAttachReqIPCCallResult : public IPCCallResultBase
{
public:
	SendAppAttachReqIPCCallResult();
	virtual ~SendAppAttachReqIPCCallResult();

	virtual retT readFromBuffer( boost::shared_ptr<asyframe::IoBuffer> _pBuffer);
	virtual retT writeToBuffer( boost::shared_ptr<asyframe::IoBuffer> _pBuffer);

	virtual std::size_t size();
	virtual retT attachRootElement(boost::weak_ptr<asyframe::PacketElement> _pRootElement);

	SerializeString strIP_;
};
